let w = {}
import { MessageBox } from 'element-ui';

const confirm  = MessageBox.confirm
const alert  = MessageBox.alert

w.confirm = function (text, fn) {
    confirm(`${text}, 是否继续?`, "提示", {
      confirmButtonText: "确定",
      cancelButtonText: "取消",
      type: "warning"
    })
      .then(() => {
        fn();
      })
      .catch(() => {
        console.log('点击了取消')
        return false;
      });
  }
 w.messages =function(code, text) {
    if (code == 1) {
      alert(text, "提示", {
        confirmButtonText: "确定",
        type: "success"
      });
    } else {
        alert(text, "提示", {
        confirmButtonText: "确定",
        type: "error"
      });
    }
  }
export default  w
